Skip to content

fix(sdk): force_flush returns meaningful bool on MetricReader#5085

Open
ravitheja4531-cell wants to merge 1 commit intoopen-telemetry:mainfrom
ravitheja4531-cell:fix/force-flush-return-meaningful-bool
Open

fix(sdk): force_flush returns meaningful bool on MetricReader#5085
ravitheja4531-cell wants to merge 1 commit intoopen-telemetry:mainfrom
ravitheja4531-cell:fix/force-flush-return-meaningful-bool

Conversation

@ravitheja4531-cell
Copy link
Copy Markdown

Fixes #5020

Description

force_flush on MetricReader and PeriodicExportingMetricReader always
returned True regardless of whether the export succeeded or failed, violating
the OTel specification:

ForceFlush SHOULD provide a way to let the caller know whether it succeeded,
failed or timed out.

This PR threads the actual export result up through _receive_metrics
collectforce_flush so callers get a meaningful bool.

Also fixes a pre-existing bug where detach(token) in
PeriodicExportingMetricReader._receive_metrics was only called on the happy
path — moved to finally so it always runs.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Ran the full existing metrics test suite locally:

Fixes open-telemetry#5020

Signed-off-by: Ravi Theja <ravitheja4531@gmail.com>
@ravitheja4531-cell
Copy link
Copy Markdown
Author

ravitheja4531-cell commented Apr 14, 2026

could someone from @jd take a look when you have a moment?
Happy to make any changes needed. Thanks!

@Asquator
Copy link
Copy Markdown

I personally like this pretty much. After it's merged, we'll have to open a new issue to indicate failure reason.

Will look at the code with more attention soon.

Btw, are you planning to add unit tests for the new behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

force_flush should provide a way to let the caller know whether it succeeded, failed or timed out.

2 participants